package com.top.mall.jetpack.ma

import com.top.mall.app.BaseApplication
import com.top.mall.base.BaseManager
import com.top.mall.entity.*
import rxhttp.RxHttp
import rxhttp.await

class GoodsManager : BaseManager() {

    /**
     * 分类列表
     *
     * @param pid
     * */
    suspend fun categoryList(pid: Int): CateListResponse =
        RxHttp.get("/api/goods/categoryList")
            .add("pid", pid)
            .await()

    /**
     * 物品列表
     *
     * @param maps 请求参数
     * */
    suspend fun goodsList(maps: Map<String, String?>): GoodsListResponse =
        RxHttp.get("/api/goods/goodsList")
            .addAll(maps)
            .await()

    /**
     * 商品标签
     * */
    suspend fun goodsService(): GoodsLabelResponse =
        RxHttp.get("/api/goods/goodsService")
            .await()


    suspend fun goodsInfo(goodsId: Int): GoodsDetailsResponse =
        RxHttp.get("/api/goods/goodsInfo")
            .add("warehouse_no", BaseApplication.WAREHOUSE_NO)
            .add("id", goodsId)
            .await()
}